import axios from 'axios'

let onquest = axios.create({
    responseType: 'json',
    baseURL: '/proxy/',
    transformRequest: [function (data) {
        // 对 data 进行任意转换处理
        return data;
    }],
    transformResponse: [function (data) {
        // 对 data 进行任意转换处理
        console.log(data)
        let o = {}
        if(data.banner){
            o.data = data.data;
            o.banner = data.banner
            o.origin = 'new-song'
        }else if(data.list){
            o.data = data.list;
            o.origin = 'singer'   
        }else if(data.rank){
            o.data = data.rank.list;
            o.origin = 'rank'
        }else if(data.plist){
            o.data = data.plist.list.info;
            o.origin = 'plist'
        }else if(data.sons){
            o.data = data.songs.list;
            o.info = data.info;
            o.origin = 'singers-info'
        }else if(data.singers){
            o.data = data.singers.list.info;
            o.info = data.info;
            o.origin = 'singer-info'
        }
        return o;
    }],
})

export const getNewSongs = (song) => {
     return onquest('?json=true',{data:song});
}

export const getRank = (song) => {
   return onquest('/rank/list/?json=true',{data:song});
}

export const getList = (song) => {
    return onquest('/plist/index?json=true',{data:song});
 }
 

export const getSinger = (song) => {
   return onquest('/singer/class?json=true',{data:song});
}


